﻿<!--#include file="../Inc/easp/easp.asp"-->
<!--#include file="../Inc/conn1.asp"-->
<!--#include file="../inc/checklogin.asp"-->
<!--#include file="../inc/easyide.asp"-->
<% CheckLogin("index.asp") %>
<%
	If Session("Authority")<>"0" Then
		Response.Write "<script type=""text/javascript"">top.location.href='../main.asp';</script>"
	end if			
	
	Dim u_id,g_id,auth,p,p1
	u_id = Easp.Get("uid")'获取用户ID
	g_id = Easp.Get("gid")'获取组ID.这个只会在选择组下拉列表时用的，本页面刷新
	auth = Easp.Get("auth")'获取权限值.这个只会在选择组下拉列表时用的，本页面刷新
	p = Easp.Get("p")'获取密码
	p1 = Easp.Get("p1")'获取重输密码
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Modify User</title>
<link rel="stylesheet" type="text/css" href="../css/theme.css" />
<link rel="stylesheet" type="text/css" href="../css/style.css" />
<script type="text/javascript">
	var StyleFile = "theme" + document.cookie.charAt(6) + ".css";
	document.writeln('<link rel="stylesheet" type="text/css" href="../css/' + StyleFile + '">');
</script>
<script language="javascript" type="text/javascript">
	function selectOption(arr)
	{
		var options = form.CountryList;		
		for(k = 0;k < arr.length;++k)
		{
			for(i = 0; i < options.length; ++i)
		  {
		  	
			  if(options[i].value == arr[k])
			  {
				  options[i].selected = true;
			  }
		  }
		}		
	}	

	function getRadioValue(radioName)
	{	  
	  var obj = document.getElementsByName(radioName);	  
	  if (obj != null)
	  {
	    var i;
		for (i = 0; i < obj.length; ++i)
		{		  
		  if(obj[i].checked)
		  {
		    return obj[i].value;
		  }
		}
	  }
	  return null;
	}

	function change(uid)
	{
	    var obj = document.getElementById("GroupList");
	    var selectedindex = obj.selectedIndex;
	    var gid = obj.options[selectedindex].value;
		  var atu = getRadioValue("radio");
		  var p = document.getElementById("password").value;
		  var p1 = document.getElementById("password1").value;

		  top.location.href="modify.asp?uid=" + uid + "&gid=" + gid + "&auth=" + atu + "&p=" + p + "&p1=" + p1;
	}
	
	function checkform(obj)
	{
		if (obj["password"].value != "" && 
		    obj["password1"].value == "")
		{
			alert("Please Input Password Again!")			
			obj["password1"].focus();
			return false;
		}
		else if (obj["password"].value =="" &&
			obj["password1"].value != "")
		{
			alert("Please Input Password!")
			obj["password"].focus();
			return false;
		}
		else if (obj["password"].value != obj["password1"].value)
		{
			alert("Password is not consistent!");
			obj["password"].focus();
			return false;
		}
		
		if(confirm("Are you sure?"))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
</script>
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="../css/ie-sucks.css" />
<![endif]-->
</head>
<body>
<div id="container">
	<div id="header">
    <div id="divAccount" style="float:right;">
        <a href="../user/account.asp" style="color:white">Account</a>&nbsp;&nbsp;&nbsp;&nbsp;
        <a href="../inc/logout.asp" style="color:white">Logout</a>
      </div>
		<h2>Modify User</h2>
		<div id="topmenu">
			<ul>
				<li><a href="../main.asp">Home</a></li>
				<li><a href="../Country/index.asp">Country</a></li>
				<li><a href="../holiday/index.asp">Holiday</a></li>
				<li><a href="../Times/index.asp">Times</a></li>
				<li><a href="../wallboard/index.asp">WallBoard</a></li>
				<% 
				    If Session("Authority")="0" Then 
				        Response.Write("<li class=""current""><a href='#'>User</a></li>")
				    End if
				%>
				<li><% If Session("Passed")=true Then %><a href="../inc/logout.asp">Logout</a><% End If %></li>
			</ul>
		</div>
	</div>
	<div id="top-panel">
		<div id="panel">
			<ul>
				<li><a href="index.asp" class="goback">GoBack</a></li>
			</ul>
		</div>
	</div>
	<div id="wrapper">
		<div id="content">
			<div id="rightnow">
				<h3 class="reallynow"> 
					<span>Modify User</span> 					
					<br />
				</h3>				
					<form id="form" action="Modifyuser.asp" method="post" onsubmit="return checkform(this);">
				    <div id="box">
					    <table style="width:500px;text-align: center;margin:auto;">						    
						    <tbody>
						    	<tr>
						    		<td style="border:0">Enter Password:</td>
						    		<td style="border:0">
						    			<input id="password" name="password" type="password" tabindex="1" class="ipt" <% if p <> "" then Easp.w "value='" & p & "'" %>/>
						    		</td>
						    	</tr>
						    	<tr>
						    		<td style="border:0">Re-Enter Password:</td>
						    		<td style="border:0">
						    			<input id="password1" name="password1" type="password" tabindex="1" class="ipt" <% if p1 <> "" then Easp.w "value='" & p1 & "'" %>/>
						    		</td>
						    	</tr>
						      <tr>
						      	<td style="border:0">Authority:</td>
						        <td style="border:0">
								  <%
								    If auth = "1" then
						        	Easp.wc "<input type='radio' id='radio' name='radio' value='2' />&nbsp;Read & Write"
           				    Easp.wc "<input type='radio' id='radio' name='radio' value='1' checked/>&nbsp;Read Only"
									  Else
									    Easp.wc "<input type='radio' id='radio' name='radio' value='2' checked />&nbsp;Read & Write"
           				    Easp.wc "<input type='radio' id='radio' name='radio' value='1'/>&nbsp;Read Only"
									  End If 
								  %>
						        </td>
						      </tr>
							  <tr>
							    <td style="border:0">Group:</td>
								<td style="border:0">
								  <select id="GroupList" name="GroupList" style="width:200px" onchange="change('<%=u_id %>');">								   
								    <%
								     Dim curgid
									   Dim rsgroup
									   Set rsgroup = Easp.db.GetRecordBySql("select * from [Group]")'查询所有组
									   If Not Easp.IsN(rsgroup) Then
									     if g_id<>"" then curgid = g_id else curgid = rsgroup("ID")'取当前显示的组ID。用来显示该组的国家用
									     While Not rsgroup.eof
										     Easp.w "<option value='" & rsgroup("ID") & "'"                                           
                         If g_id = Trim(rsgroup("ID")) Then
										       Easp.w "selected"
                         End If 
                         Easp.wc ">" & rsgroup("GroupName") & "</option>"
                         rsgroup.movenext()
										   Wend 
									   End If
									   Easp.db.C(rsgroup)
									%>									
								  </select>
								</td>
							  </tr>
						      <tr>
						      	<td style="border:0">Dispatch Country:</td>
						      	<td style="border:0">
						      		<select id="CountryList" name="CountryList" size="10" multiple="multiple" style="width:200px">
						      			<%
						      			  '添加国家列表
						      			  dim rs
						      			  set rs = Easp.db.GetRecordBySql("select * from Country where g_id=" & curgid)'显示所有国家
						      			  If not Easp.IsN(rs) Then
						      			  	while not rs.eof
						      			  	  Easp.wc "<option value='" & rs("y_id") & "'>" & rs("CountryName") & "</option>"
						      			  	  rs.MoveNext()
						      			  	wend
						      			  End If
						      			  Easp.db.C(rs)
						      			%>
						      		</select>
						      	</td>						      	
						      </tr>
						    </tbody>
						  </table>
						  <div id="pager">						  	  
						  	<%
						  	  '选中已管理的国家
						  	  dim rs1,param
						  	  'Set rs1 = Easp.db.GetRecordBySql("select * from Country where u_id=" & Easp.Get("uid") & "")
						  	  set rs1 = Easp.db.GetRecordBySql("SELECT Country.y_id, Country.g_id, Country.CountryName, Country.HolidayFile, Country.TimesFile FROM Country INNER JOIN UserCountry ON Country.y_id = UserCountry.CountryID WHERE (([UserCountry].[UserID]= " & Easp.Get("uid") & ")) ORDER BY Country.y_id")
						  	  param = ""
						  	  If not Easp.IsN(rs1) Then
						  	  	while not rs1.eof
						  	  	  param = param & rs1("y_id") & ","
						  	  	  rs1.MoveNext()
						  	  	wend
						  	  End If
						  	  Easp.db.C(rs1)
						  	  if param<>"" Then
						  	  	param = str_left(param, str_len(param) - 1, "")
						  	  end if
						  	  
						  	  Easp.wc "<script type=""text/javascript"">selectOption(new Array(" & param & ",-1));</script>"
						  	%>
						  	<input type='hidden' id='uid' name='uid' value='<%=Easp.Get("uid") %>' />
						  	<input class='btn' type='submit' name='submit' value='Alter' />
						    <input class='btn' type='reset' name='reset' value='Reset' />
						  </div>
						</div>
					</form>				
			</div>
		</div>
	</div>
	<!--#include file="../inc/footer.asp" -->
</div>
</body>
</html>

